<?php

namespace App\Admin\Renderable;

use Dcat\Admin\Grid;
use App\Models\SchoolUser;
use Dcat\Admin\Grid\LazyRenderable;


class StudentTable extends LazyRenderable
{
    public function grid(): Grid
    {
        return Grid::make(new SchoolUser(['school']), function (Grid $grid) {
            $grid->column('id')->sortable();
            $grid->column('real_name', '姓名');
            $grid->column('school.name','学校');
            $grid->column('account','上网账号');
            $grid->column('tel','电话');
            $grid->column('id_card','身份证号');
            $grid->column('enable','状态')->bool();
            $grid->column('memo','备注');
            $grid->column('created_at')->format('Y-m-d H:i:s');
            $grid->column('updated_at')->format('Y-m-d H:i:s');
            $grid->filter(function (Grid\Filter $filter) {
                $filter->panel();
                $filter->equal('id')->width(2);
                $filter->like('real_name','姓名')->width(2);
                $filter->like('account','上网账号')->width(2);
                $filter->like('tel','电话')->width(2);
                $filter->like('id_card','身份证号')->width(2);
                $filter->equal('enable','状态')->select([1 => '可用', 0 => '禁用'])->width(2);
                $filter->like('memo','备注')->width(2);
            });
            $grid->disableActions();

            // $grid->paginate(5);
            $grid->disablePagination();
        });
    }
}
